package com.quanshu.exchange.ui.gui.message.group.dialog;

import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.view.Gravity;
import android.view.Window;
import android.view.WindowManager;
import android.widget.TextView;

import com.quanshu.exchange.R;
import com.quanshu.exchange.support.utils.RxViewHelper;
import com.quanshu.exchange.ui.base.BaseDialog;

import butterknife.BindView;
import butterknife.ButterKnife;
import io.reactivex.subjects.BehaviorSubject;

/**
 * Created by jye on 2018/1/17.
 */

public class DialogExitGroupChat extends BaseDialog {

    @BindView(R.id.dialog_click_delete)
    TextView dialogLongClickDelete;
    @BindView(R.id.dialog_click_cancel)
    TextView dialogLongClickCancel;

    public BehaviorSubject getDeleteSubject() {
        return deleteSubject;
    }

    private BehaviorSubject deleteSubject = BehaviorSubject.create();

    public DialogExitGroupChat(@NonNull Context context) {
        super(context);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_exit_group_chat);
        ButterKnife.bind(this);
        initListener();
    }

    @Override
    public void init(@NonNull Context context) {
        Window window = getWindow();
        window.setWindowAnimations(R.style.BottomAnim);
        window.setGravity(Gravity.BOTTOM);
        //默认的Dialog只有5/6左右的宽度，改为全屏宽度,由dialog的布局自己来决定实际显示宽度
        window.getDecorView().setPadding(0, 0, 0, 0);
        WindowManager.LayoutParams lp = window.getAttributes();
        lp.width = WindowManager.LayoutParams.MATCH_PARENT;
        lp.height = WindowManager.LayoutParams.WRAP_CONTENT;
        window.setAttributes(lp);
    }

    private void initListener() {

        RxViewHelper.getInstance().clicks(dialogLongClickDelete, aVoid -> deleteSubject.onNext(aVoid));
        RxViewHelper.getInstance().clicks(dialogLongClickCancel, aVoid -> dismiss());

    }


}
